

<template>
<view>
  <view class="user-activity-menu">
    <view v-for="item in assetTypeList" class="menu-item" @click="openPopup(item)">
      <view class="left">
        <text :class="'iconfont '+item.icon " style="font-size: 30px;"></text>
        <view class="menu-name">{{ item.type_title }}</view>
      </view>
      <text class="iconfont icon-right ml-6 text-333"></text>
    </view>
    <AssetUpdate :visible="showPopup" ref="assetUpdateRef" :title-update="true" @close="closePopup"  :obj="asset" @updateConfirm="updateConfirm"></AssetUpdate>

  </view>
</view>
</template>
<script>
import {
  getAssetType
} from '@/api/api.js';
import {useSystem} from "@/store/theme";
import AssetUpdate from "./AssetUpdate.vue";
import {addAsset} from "../../api/api";
export default {
  name: "assetTypeList",
  data(){
    return{
      assetTypeList:[],

      asset:{},
      showPopup:false
    }
  },

  setup() {
    const systemTheme = useSystem()
    return {systemTheme}
  },

  components:{
    AssetUpdate
  },

  onLoad(){
    this.getData();
  },
  onShow(){
    uni.setNavigationBarColor({
      backgroundColor: this.systemTheme.bg //背景颜色值，有效值为十六进制颜色
    })
  },
  methods:{
    closePopup(){
      this.showPopup = false
    },
    async updateConfirm(e){
		console.log('eee',e)
      await addAsset(e,true);
      this.showPopup = false
    },
    openPopup(item){
      if(item.childNum != null && item.childNum > 0){
        uni.navigateTo({
          url: '/components/index-list/t-index-list?parent_id='+item.id
        })
      }else{
        this.asset = {
          type_id: item.id,
          title: item.type_title,
          icon:item.icon
        }
        this.showPopup = true
      }
    },
    async getData(){
      uni.showLoading({title:"加载中"})
      this.assetTypeList = await getAssetType(true, 0)

      uni.hideLoading()
    }
  },

}
</script>
<style scoped lang="scss">
.user-activity-menu {
  padding: 30rpx;
  margin: 20rpx;
  border-radius: 20rpx;
  background: #fff;

  .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 60rpx;

    .left {
      display: flex;
      align-items: center;

      .menu-icon {
        width: 40rpx;
        height: 40rpx;
      }


      .menu-name {
        font-size: 28rpx;
        margin-left: 20rpx;
      }
    }

    .menu-number {
      font-size: 30rpx;

      letter-spacing: 2rpx;
    }
  }

  .menu-item:first-child {
    margin-top: 0;
  }
}
</style>